<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('box_setting')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="'https://images.weserv.nl/?url='+getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <box-setting-modal ref="modalForm" @ok="modalFormOk"></box-setting-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import BoxSettingModal from './modules/BoxSettingModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'BoxSettingList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      BoxSettingModal
    },
    data () {
      return {
        description: 'box_setting管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'App下载地址',
            align:"center",
            dataIndex: 'appurl'
          },
          {
            title:'新手教程',
            align:"center",
            dataIndex: 'tutorialfile'
          },
          {
            title:'首页弹窗开关',
            align:"center",
            dataIndex: 'syswitch_dictText'
          },
          {
            title:'奖励幸运币',
            align:"center",
            dataIndex: 'shareJl'
          },
          {
            title:'奖励优惠券ID',
            align:"center",
            dataIndex: 'couponId'
          },
          {
            title:'返佣比例',
            align:"center",
            dataIndex: 'shareFy'
          },
          {
            title:'新人首次兑换获得重抽卡ID',
            align:"center",
            dataIndex: 'cardId'
          },
          {
            title:'客服二维码',
            align:"center",
            dataIndex: 'kfimage',
            scopedSlots: {customRender: 'imgSlot'}
          },
          {
            title:'小程序ID',
            align:"center",
            dataIndex: 'mpappid'
          },
          {
            title:'小程序密钥',
            align:"center",
            dataIndex: 'mpappkey'
          },
          {
            title:'微信支付商户号',
            align:"center",
            dataIndex: 'payid'
          },
          {
            title:'微信支付密钥',
            align:"center",
            dataIndex: 'paykey'
          },
          {
            title:'连抽优惠比例',
            align:"center",
            dataIndex: 'lcyhbl'
          },
          {
            title:'快递100key',
            align:"center",
            dataIndex: 'kdkey'
          },
          {
            title:'快递100customer',
            align:"center",
            dataIndex: 'kdcustomer'
          },
          {
            title:'阿里云id',
            align:"center",
            dataIndex: 'accessid'
          },
          {
            title:'阿里云key',
            align:"center",
            dataIndex: 'accesskey'
          },
          {
            title:'OSS实例地址',
            align:"center",
            dataIndex: 'endpoint'
          },
          {
            title:'OSS存储空间名称',
            align:"center",
            dataIndex: 'bucket'
          },
          {
            title:'APP支付宝支付ID',
            align:"center",
            dataIndex: 'appid'
          },
          {
            title:'APP支付应用私钥',
            align:"center",
            dataIndex: 'rsaprivatekey'
          },
          {
            title:'APP支付应用公钥',
            align:"center",
            dataIndex: 'alipayrsapublickey'
          },
          {
            title:'APP微信登录ID',
            align:"center",
            dataIndex: 'wxappid'
          },
          {
            title:'App微信登录key',
            align:"center",
            dataIndex: 'wxappkey'
          },
          {
            title:'易支付ID',
            align:"center",
            dataIndex: 'yzfid'
          },
          {
            title:'易支付密钥',
            align:"center",
            dataIndex: 'yzfkey'
          },
          {
            title:'易支付地址',
            align:"center",
            dataIndex: 'yzfurl'
          },
          {
            title:'boxflId',
            align:"center",
            dataIndex: 'boxflId'
          },
          {
            title:'domain',
            align:"center",
            dataIndex: 'domain'
          },
          {
            title:'一级会员返佣比例',
            align:"center",
            dataIndex: 'first'
          },
          {
            title:'二级会员返佣比例',
            align:"center",
            dataIndex: 'second'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/setting/boxSetting/list",
          delete: "/setting/boxSetting/delete",
          deleteBatch: "/setting/boxSetting/deleteBatch",
          exportXlsUrl: "/setting/boxSetting/exportXls",
          importExcelUrl: "setting/boxSetting/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'appurl',text:'App下载地址',dictCode:''})
        fieldList.push({type:'string',value:'tutorialfile',text:'新手教程',dictCode:''})
        fieldList.push({type:'int',value:'syswitch',text:'首页弹窗开关',dictCode:'yn'})
        fieldList.push({type:'BigDecimal',value:'shareJl',text:'奖励幸运币',dictCode:''})
        fieldList.push({type:'int',value:'couponId',text:'奖励优惠券ID',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'shareFy',text:'返佣比例',dictCode:''})
        fieldList.push({type:'int',value:'cardId',text:'新人首次兑换获得重抽卡ID',dictCode:''})
        fieldList.push({type:'string',value:'kfimage',text:'客服二维码',dictCode:''})
        fieldList.push({type:'string',value:'mpappid',text:'小程序ID',dictCode:''})
        fieldList.push({type:'string',value:'mpappkey',text:'小程序密钥',dictCode:''})
        fieldList.push({type:'int',value:'payid',text:'微信支付商户号',dictCode:''})
        fieldList.push({type:'string',value:'paykey',text:'微信支付密钥',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'lcyhbl',text:'连抽优惠比例',dictCode:''})
        fieldList.push({type:'string',value:'kdkey',text:'快递100key',dictCode:''})
        fieldList.push({type:'string',value:'kdcustomer',text:'快递100customer',dictCode:''})
        fieldList.push({type:'string',value:'accessid',text:'阿里云id',dictCode:''})
        fieldList.push({type:'string',value:'accesskey',text:'阿里云key',dictCode:''})
        fieldList.push({type:'string',value:'endpoint',text:'OSS实例地址',dictCode:''})
        fieldList.push({type:'string',value:'bucket',text:'OSS存储空间名称',dictCode:''})
        fieldList.push({type:'string',value:'appid',text:'APP支付宝支付ID',dictCode:''})
        fieldList.push({type:'Text',value:'rsaprivatekey',text:'APP支付应用私钥',dictCode:''})
        fieldList.push({type:'Text',value:'alipayrsapublickey',text:'APP支付应用公钥',dictCode:''})
        fieldList.push({type:'string',value:'wxappid',text:'APP微信登录ID',dictCode:''})
        fieldList.push({type:'string',value:'wxappkey',text:'App微信登录key',dictCode:''})
        fieldList.push({type:'string',value:'yzfid',text:'易支付ID',dictCode:''})
        fieldList.push({type:'string',value:'yzfkey',text:'易支付密钥',dictCode:''})
        fieldList.push({type:'string',value:'yzfurl',text:'易支付地址',dictCode:''})
        fieldList.push({type:'int',value:'boxflId',text:'boxflId',dictCode:''})
        fieldList.push({type:'string',value:'domain',text:'domain',dictCode:''})
        fieldList.push({type:'int',value:'first',text:'一级会员返佣比例',dictCode:''})
        fieldList.push({type:'int',value:'second',text:'二级会员返佣比例',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>